'use strict';
app.controller('agentAreaDeleteCtrl', ['$scope', '$modalInstance', 'agentAreaService', 'toaster', 'modalData', '$state',
    function($scope, $modalInstance, agentAreaService, toaster, modalData, $state) {

        $scope.isDelModal=true;
        $scope.id=modalData.data.id;

        //确认删除
        $scope.ok = function(){
            if(!$scope.isDelModal){
                return;
            }
            $scope.isDelModal = false;
            agentAreaService.delete($scope).then(function(result){
                switch (result.status){
                    case 200:
                        toaster.pop('success', "提示", "操作成功");
                        $scope.cancel();
                        $state.reload('app.agentArea');
                        $scope.isDelModal=true;
                        break;
                    default :
                        toaster.pop('error', "删除失败", result.message);
                        $scope.isDelModal=true;
                        break;
                }
            });
        }
        //取消弹窗
        $scope.cancel = function () {
            $modalInstance.dismiss('cancel');
        };
}]);